<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.springframework.org/schema/jdbc" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<link rel="stylesheet" th:href="@{/assets/css/colorbox.css}"/>
<head th:include="fragments/head::header"/>
<style>
    .error {
        color: #F00
    }
</style>
<body>
<div th:include="fragments/top::top"></div>
<div class="main-container" id="main-container">
    <div class="main-container-inner">
        <div th:include="fragments/left::left" class="sidebar" id="sidebar"></div>
        <div class="main-content">
            <div class="breadcrumbs" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li>学生列表</li>
                    <li>院校申请</li>
                    <li>offer结果列表</li>
                </ul>
            </div>

            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="row">
                            <div class="col-xs-12">
                                <div th:include="fragments/student_info::student_info"
                                     th:style="${session.studentInfoKey == null}? 'display:none'"></div>
                                <h3 class="header smaller lighter blue">申请结果列表</h3>
                                <input type="hidden" name="applyId" id="applyId"
                                       th:value="${#httpServletRequest.getParameter('applyId')}"/>
                                <input type="hidden" name="studentNo" id="studentNo"
                                       th:value="${#httpServletRequest.getParameter('studentNo')}"/>
                                <input type="hidden" name="oaid" id="oaid" th:value="${session.user.oaid}"/>
                                <input type="hidden" id="nationId" th:value="${nationId != null} ? ${nationId}"/>
                                <input type="hidden" id="nationStatus" th:value="${nationStatus != null} ? ${nationStatus}"/>
                                <shiro:hasPermission name="院校申请结果_删除">
                                    <input type="hidden" name="isConnector" id="isConnector" th:value="1"/>
                                </shiro:hasPermission>
                                <shiro:hasPermission name="院校申请列表_查看">
                                    <input type="hidden" name="checkPermission" id="checkPermission" th:value="true"/>
                                </shiro:hasPermission>
                                <shiro:hasRole name="运营人员">
                                    <input type="hidden" name="operator" id="operator" th:value="1"/>
                                </shiro:hasRole>
                                <shiro:hasRole name="外联经理">
                                    <input type="hidden" name="connectorLeader" id="connectorLeader" th:value="1"/>
                                </shiro:hasRole>
                                <input type="hidden"  id="applyStatus" th:value="${applyStatus}"/>
                                <div class="table-header">
                                    <form class="form-inline">
                                        <div class="form-group">
                                            <label for="result_type">申请结果：</label>
                                            <select type="" class="form-control input-sm" id="result_type"
                                                    style="width:100px;">
                                                <option value="" selected="selected">全部</option>
                                                <option value="1">录取</option>
                                                <option value="2">拒绝</option>
                                                <option value="3">满位</option>
                                                <option value="4">waiting list</option>
                                                <option value="5">预录取</option>
                                            </select>
                                        </div>
                                        <button type="button" id="query" class="btn btn-success ">查询</button>
                                        <button type="reset" class="btn btn-warning">清空</button>
                                        <a id="addButton" href="javascript:void(0)" onclick="toAddURL()" data-toggle="modal"
                                           data-target="#myModal"
                                           class="btn btn-info pull-right">添加申请结果</a>
                                        <a href="javascript:void(0)" onclick="returnApplyList()" data-toggle="modal"
                                           data-target="#myModal"
                                           class="btn btn-info pull-right">院校申请列表</a>
                                        <a id="toStudent" th:href="@{/studentInfo}" class="btn btn-info pull-right">学生列表</a>
                                    </form>
                                </div>

                                <div class="table-responsive">
                                    <div id="alert" class="alert alert-success" style="display: none;" role="alert">
                                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                            <span aria-hidden="true">&times;</span>
                                        </button>
                                        <span id="alertText"></span>
                                    </div>
                                    <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                                        <thead>
                                        <tr>
                                            <th class="hide">id</th>
                                            <th>审批状态</th>
                                            <th>申请结果</th>
                                            <th>Offer类型</th>
                                            <th>Offer附件</th>
                                            <th>学生是否确认</th>
                                            <th>回复日期</th>
                                            <th>操作人</th>
                                            <th>操作日期</th>
                                            <th width="25%" class="hidden-480">操作</th>
                                        </tr>
                                        </thead>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.page-content -->
        </div>

        <div th:include="fragments/bottom::bottom"></div>
    </div>

    <a href="#" id="btn-scroll-up"
       class="btn-scroll-up btn btn-sm btn-inverse"> <i
            class="icon-double-angle-up icon-only bigger-110"></i>
    </a>
</div>
<!-- /.main-container -->

<!-- Modal备注 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content"></div>
    </div>
</div>
<div th:include="fragments/js::js"></div>

<script th:src="@{/assets/js/jquery.validate.min.js}"></script>
<script th:src="@{/assets/js/jquery.validate.zh-CN.js}"></script>
<!-- page specific plugin scripts -->
<script th:src="@{/assets/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/assets/js/jquery.dataTables.bootstrap.js}"></script>
<script th:src="@{/assets/js/temp.js}" charset="UTF-8"></script>
<!--图片查看器-->
<script th:src="@{/assets/js/jquery.colorbox-min.js}"></script>
<script th:src="@{/layer/layer.js}"></script>
<script th:src="@{/business/applyResult/list.js}"></script>
<script type="text/javascript">
    /*<![CDATA[*/

    var oTable1;
    var studentNo = $("#studentNo").val();
    jQuery(function ($) {
        oTable1 = $('#sample-table-2').dataTable({
            "bFilter": false,//是否使用搜索
            "bProcessing": true,
            "bDeferRender": true,//
            "sPaginationType": "bs_normal",//分页样式
            "bRetrieve": true,//是否调用后台
            "bServerSide": true,//是否以后台分页
            "sAjaxSource": "/applyResult/list/query",//请求路径
            "fnServerData": function (sSource, aoData, fnCallback) {
                aoData.push(
                    {"name": "applyId", "value": $("#applyId").val()},
                    {
                        "name": "resultType",
                        "value": $("#result_type").find("option:selected").val() == "" ? null : $("#result_type").find("option:selected").val()
                    }
                )
                $.ajax({
                    "dataType": 'json',
                    "type": "GET",
                    "url": sSource,
                    "data": aoData,
                    "success": fnCallback
                });
            },
            "aaSorting": [[0, "desc"]],
            "bSort": true,
            "aoColumns": [
                {"sClass": "center", "bVisible": false, "mData": "id"},//此列不显示
                {
                    "sClass": "center", "bSortable": false, "mData":
                        function (data) {

                            if (data.auditStatus == 1) return "已提交";
                            if (data.auditStatus == 2) return "审批中";
                            if (data.auditStatus == 3) return "审批通过";
                            if (data.auditStatus == 4) return "审批不通过";
                            return "--";

                        }
                },
                {
                    "sClass": "center", "bSortable": false, "mData":
                        function (data) {
                            if (data.resultType == 1) return "录取";
                            if (data.resultType == 2) return "拒绝";
                            if (data.resultType == 3) return "满位";
                            if (data.resultType == 4) return "waiting list";
                            if (data.resultType == 5) return "预录取";
                            if (data.resultType == 6) return "其他";
                            if (data.resultType == 7) return "收条";
                        }
                },
                {
                    "sClass": "center", "bSortable": false, "mData":
                        function (data) {
                            if (data.offerType == 1) return "无条件offer";
                            if (data.offerType == 2) return "只有语言条件offer";
                            if (data.offerType == 3) return "只有学术条件offer";
                            if (data.offerType == 4) return "其他条件offer";
                            else return "无";
                        }
                },
                {
                    "sClass": "center", "bSortable": false, "mData": function (data) {
                    if (data.offerAttachment == null || data.offerAttachment == "") {
                        return null;
                    }
                    else {
                        var showImg = '<a onclick="showAttachment(\'' + data.offerAttachment + '\')">查看</a>';
                        return showImg;
                    }
                    }
                },
                {"sClass": "center", "bSortable": false, "mData":
                    function (data) {

                        if(data.studentReply==0) return "未确认";
                        if(data.studentReply==1) return "已确认";
                        else return "";
                    }
                },
                {"sClass": "center", "bSortable": false, "mData": "resultDateString"},
                {"sClass": "center", "bSortable": false, "mData": "operatorName"},
                {"sClass": "center", "bSortable": false, "mData":
                    function(data){
                        return getTimeString(new Date(data.createTime))
                    }
                },
                {
                    "sClass": "center", "bSortable": false, "mData": function (data) {
                        var styleDiv = '<div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">';

                        var check = '<a href="javascript:void(0);" onclick="toDetail(' + data.id + ',\'' + studentNo + '\')">查看</a>';
                        var editOperation = "";
                        var deleteOperation = "";

                        if($("#checkPermission").val() == "true"){
                            return check;
                        }

                        if($("#isConnector").val() == "1") {
                            if(($("#operator").val() == "1" && data.auditStatus == 3) || (($("#connectorLeader").val() == "1" && data.auditStatus < 3))) {
                                deleteOperation = '<a  href="javascript:void(0);"  onclick="toDelete(' + data.id + ',this)">删除</a>';
                            }

                        }
                        var studentTime = "";
                        var schoolTime = "";
                        if (data.auditStatus != 3) {
                            if ($("#oaid").val() == data.operatorNo || $("#connectorLeader").val() =="1") {
                                editOperation = '<a href="javascript:void(0);" onclick="toEditURL(' + data.id + ',' + data.auditStatus + ',' + $("#nationStatus").val() + ')">修改</a>';
                                //deleteOperation='<a href="javascript:void(0);"  onclick="toDelete('+data.id+')">删除</a>';
                            }
                        } else {
                            studentTime = '<a href="javascript:void(0);" onclick="toStudentConfirm(' + data.id + ')" >学生确认</a>';
                            schoolTime = '<a href="javascript:void(0);" onclick="toSchoolConfirm(' + data.id + ')" >学校确认</a>';
                        }
                        if (data.studentReplyDate != null) {
                            studentTime = '';
                        }
                        if (data.schoolReplyDate != null) {
                            schoolTime = '';
                        }
                        var styleDiv_end = '</div>';
                        return styleDiv + check + editOperation + deleteOperation + studentTime + schoolTime + styleDiv_end;
                    }
                }
            ],
            "oLanguage": {
                "sLengthMenu": "每页 _MENU_条 ",
                "sZeroRecords": "对不起，查询不到任何相关数据",
                "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录 ",
                "sInfoEmpty": "显示 0 到 0 条，共 0 条记录",
                "sInfoFiltered": "数据表中共为 _MAX_ 条记录)",
                "sProcessing": "正在加载中...",
                "sSearch": "搜索",
                "sUrl": "", //多语言配置文件，可将oLanguage的设置放在一个txt文件中，例：Javascript/datatable/dtCH.txt
                "oPaginate": {
                    "sFirst": "第一页",
                    "sPrevious": " 上一页 ",
                    "sNext": " 下一页 ",
                    "sLast": " 最后一页 "
                }
            }
            //多语言配置

        });


        $("#query").click(function () {
            oTable1.fnDraw();
        })

        $(function(){
            if($("#checkPermission").val() == "true"){
                $("#addButton").hide();
                $("#toStudent").hide();
            }
        });

    })

    function showAttachment(showAttachment) {
//        if (showAttachment.indexOf($("#resDomain").val()) == -1) {
//            window.open($("#resDomain").val() + URLencode(showAttachment));
//        } else {
//            window.open(URLencode(showAttachment));
//        }
        $.post("/getPrivateUrl",{"fileUrl":showAttachment},function (data,status) {
            window.open(data);
        });
//        window.open(showAttachment);
    }

    /*]]>*/
</script>
</body>
</html>
